import { store } from '@/store/index'

// 组件内部使用pinia缓存组合式api示例
export const useAppStore = defineStore('app', () => {
	const state = reactive({
		version: '0.0.1',
	})

	const getVersion = computed(() => state.version)

	const setVersion = (version: string) => {
		state.version = version
	}

	return {
		...toRefs(state),
		getVersion,
		setVersion,
	}
})

// 在组件外部使用pinia缓存
export function useAppStoreWithOut() {
	return useAppStore(store)
}
